<template>
    <div class="app-container">
        <el-row :gutter="20">
            <el-col :span="6" :xs="24">
                <el-card class="box-card">
                    <div slot="header" class="clearfix">
                        <span>我的资料</span>
                    </div>
                    <div>
                        <div class="text-center">
                            <userAvatar :user="user"/>
                        </div>
                        <ul class="list-group list-group-striped">
                            <li class="list-group-item">
                                <svg-icon icon-class="user"/>
                                账号
                                <div class="pull-right">{{ user.userName }}</div>
                            </li>
                            <li class="list-group-item">
                                <svg-icon icon-class="time"/>
                                出生日期
                                <div class="pull-right">{{ parseTime(user.birthday, '{y}-{m}-{d}') }}</div>
                            </li>
                            <li class="list-group-item">
                                <svg-icon icon-class="row"/>
                                身份证号
                                <div class="pull-right">{{ user.identity }}</div>
                            </li>
                            <li class="list-group-item">
                                <svg-icon icon-class="email"/>
                                用户邮箱
                                <div class="pull-right">{{ user.email }}</div>
                            </li>
                            <li class="list-group-item">
                                <svg-icon icon-class="phone"/>
                                手机号码
                                <div class="pull-right">{{ user.phonenumber }}</div>
                            </li>
                            <li class="list-group-item">
                                <i class="el-icon-star-off"/>性别
                                <div class="pull-right">
                                    <dict-tag style="margin-top: -5px" :options="dict.type.sys_user_sex" :value="user.sex"/>
                                </div>
                            </li>
                            <li class="list-group-item">
                                <i class="el-icon-fork-spoon"/>婚姻状态
                                <div class="pull-right">
                                    <dict-tag style="margin-top: -5px" :options="dict.type.basic_marital_dict" :value="user.userInfo.marital"/>
                                </div>
                            </li>
                            <li class="list-group-item">
                                <i class="el-icon-lollipop"/>生育状态
                                <div class="pull-right">
                                    <dict-tag style="margin-top: -5px" :options="dict.type.basic_birth_dict" :value="user.userInfo.birth"/>
                                </div>
                            </li>
                            <li class="list-group-item">
                                <i class="el-icon-s-check"/>政治面貌
                                <div class="pull-right">
                                    <dict-tag style="margin-top: -5px" :options="dict.type.basic_politics_status_dict" :value="user.userInfo.politicsStatus"/>
                                </div>
                            </li>
                            <li class="list-group-item">
                                <svg-icon icon-class="tree"/>
                                所属科室
                                <div class="pull-right" v-if="user.dept">{{ user.dept.deptName }}<!-- / {{ postGroup }}-->
                                </div>
                            </li>
<!--                            <li class="list-group-item">-->
<!--                                <svg-icon icon-class="peoples"/>-->
<!--                                所属角色-->
<!--                                <div class="pull-right">{{ roleGroup }}</div>-->
<!--                            </li>-->
                            <li class="list-group-item">
                                <svg-icon icon-class="date"/>
                                入学科时间
                                <div class="pull-right">{{ parseTime(user.createTime, '{y}-{m}-{d}') }}</div>
                            </li>
                            <li class="list-group-item">
                                <i class="el-icon-tickets"/>学历
                                <div class="pull-right">
                                    <dict-tag style="margin-top: -5px" :options="dict.type.basic_educatiod_dict" :value="user.userInfo.educatiod"/>
                                </div>
                            </li>
                            <li class="list-group-item">
                                <i class="el-icon-document-remove"/>学位
                                <div class="pull-right">
                                    <dict-tag style="margin-top: -5px" :options="dict.type.basic_degree_dict" :value="user.userInfo.degree"/>
                                </div>
                            </li>
                            <li class="list-group-item">
                                <i class="el-icon-document-copy"/>学位类型
                                <div class="pull-right">
                                    <dict-tag style="margin-top: -5px" :options="dict.type.basic_degree_type_dict" :value="user.userInfo.degreeType"/>
                                </div>
                            </li>
                            <li class="list-group-item">
                                <i class="el-icon-paperclip"/>授权最高学位院校及专业
                                <div class="pull-right">{{ user.userInfo.highestDegree }}</div>
                            </li>
                            <li class="list-group-item" v-if="user.userInfo.docCertNum == null">
                                <i class="el-icon-document-checked"/>医师资格证书
                                <div class="pull-right">无</div>
                            </li>
                            <template v-else>
                                <li class="list-group-item">
                                    <i class="el-icon-document-checked"/>医师资格证书号
                                    <el-tag type="success" class="pull-right" style="margin-top: -5px" effect="plain">
                                        {{ user.userInfo.docCertNum }}
                                    </el-tag>
                                </li>
                                <li class="list-group-item">
                                    <i class="el-icon-c-scale-to-original"/>医师资格证书获得时间
                                    <div class="pull-right">{{ user.userInfo.certGetTime }}</div>
                                </li>
                            </template>
                        </ul>
                    </div>
                </el-card>
            </el-col>
            <el-col :span="18" :xs="100">
                <el-card>
                    <div slot="header" class="clearfix">
                        <span>基本信息</span>
                    </div>
                    <el-tabs v-model="activeTab">
                        <el-tab-pane label="基本资料" name="userinfo">
                            <userInfo :user="user"/>
                        </el-tab-pane>
                        <el-tab-pane label="学历学位" name="education">
                            <education :user="user"/>
                        </el-tab-pane>
                        <el-tab-pane label="学习、工作经历（高中起）" name="experience">
                            <experience :user="user"/>
                        </el-tab-pane>
                        <el-tab-pane label="修改密码" name="resetPwd">
                            <resetPwd/>
                        </el-tab-pane>
                        <el-tab-pane label="申请更换科室" name="deptTransferApply">
                            <deptTransferApply/>
                        </el-tab-pane>
                    </el-tabs>
                </el-card>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import userAvatar from '@/views/system/user/profile/userAvatar.vue';
import userInfo from '@/views/system/user/student/userInfo.vue';
import education from '@/views/system/user/student/education.vue';
import experience from '@/views/system/user/student/experience.vue';
import resetPwd from '@/views/system/user/profile/resetPwd.vue';
import {getUserProfile} from "@/api/system/user";
import deptTransferApply from "@/views/system/user/profile/deptTransferApply.vue";

export default {
    name: "Profile",
    components: {deptTransferApply, userAvatar, userInfo, resetPwd,education,experience},
    dicts: ['sys_user_sex','basic_marital_dict', 'basic_birth_dict', 'basic_politics_status_dict',
        'basic_educatiod_dict', 'basic_degree_dict', 'basic_degree_type_dict'],
    data() {
        return {
            user: {
                userInfo: {}
            },
            roleGroup: {},
            postGroup: {},
            activeTab: "userinfo"
        };
    },
    created() {
        this.getUser();
    },
    methods: {
        getUser() {
            getUserProfile().then(response => {
                this.user = response.data;
                this.roleGroup = response.roleGroup;
                this.postGroup = response.postGroup;
            });
        }
    }
};
</script>
